<%@ page import="database.CourseDb" %>
<%@ page import="database.Course" %>
<%@ page import="java.util.List" %><%--
  Created by IntelliJ IDEA.
  User: jimmyhsu
  Date: 2016/12/16
  Time: 11:11
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
    <title>选课管理</title>
    <link rel="stylesheet" href="../../static/style/weui.css"/>
    <link rel="stylesheet" href="../../static/example/example.css"/>
    <link rel="stylesheet" href="../../static/style/myStyle.css"/>
    <link rel="stylesheet" href="../../static/css/bootstrap.css"/>
    <script type="text/javascript" src="../../static/js/myjs.js"></script>
    <%
        List<Course> futureCourses = CourseDb.selectAllFutureCourses(0, 999);

    %>
</head>
<body style="background-color: transparent; color: #ffffff;" data-spy="scroll" data-target=".bs-docs-sidebar">
<%@include file="Do/checkAdminLogin.jsp"%>
<br>
<div class="container" style="width: 80%; height: 100%;">
<h1 class = "page_title">选课</h1>
<br>
    <div class="row" style="background-color: transparent;">
        <div class="span3 bs-docs-sidebar">
        <div class="dropdown clearfix">
            <br>
            <div class="dropdown">
                <a class="dropdown-toggle" style="color: #ffffff;" id="dLabel" role="button" data-toggle="dropdown" data-target="#" href="javascript:void(0);">
                    课程列表
                    <b class="caret" style="color: #ffffff;"></b>
                </a>
                <ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">
                    <%
                        if (futureCourses.size() == 0) {%>
                    <li><a href="javascript:void(0);" tabindex="-1">没有未来的课程，赶紧去添加吧</a></li>
                    <%}else{
                        for (int i = 0; i < futureCourses.size(); i++) {
                            Course course = futureCourses.get(i);
                    %>
                    <li><a href="javascript:void(0);" tabindex="-1" onclick="clickTable('<%=course.getId()%>')"><%=course.getName()%></a></li>
                    <%
                        if (i != futureCourses.size() - 1) {
                    %>
                    <li class="divider"></li>
                    <%}}}%>
                </ul>
            </div>

        </div>
        </div>

<div class="span9">
    <iframe id = "frame" name = "frame" src = "selectCourse_Table.jsp" frameborder = "0"  width = "100%" height = "300px"></iframe>

    <br>学号
    <input type = "text" name = "studentId" />
    <input type = "hidden" name = "courseId" value=""/>

    <button class="myButton" style = "position: relative" type = "button" onclick = "mySubmit()">添加学生
    </button>
</div>
    </div>
</div>
</body>
<script src="../../static/js/jquery-1.10.2.js"></script>
<script src="../../static/js/bootstrap.js"></script>
<script>
    var currentCourseId;
    function clickTable(courseId)
    {
        currentCourseId = courseId;
        window.frame.location.href = 'selectCourse_Table.jsp?courseId='+courseId;
        document.getElementById("courseId").value=courseId;
    }

    function getCourseId()
    {
        var courseId = 0;
        currentCourseId = document.getElementsByName("courseId")[0]().value;
        return currentCourseId;
    }

    function mySubmit()    {
        if(document.getElementsByName("studentId")[0].value == "")
        {
            alert('请输入学生学号再添加！');
            return;
        }
        jsPost('addUserToCourse', {
            'studentId' : document.getElementsByName("studentId")[0].value,
            'courseId' : currentCourseId
        });
    }
    $('.dropdown-toggle').dropdown();
</script>
</html>
